﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using NUnit.Framework;
using Restful.Net.Serialization;

namespace Restful.Net.Tests
{
    [TestFixture]
    public class JsonSerializerTest
    {


        [Test]
        public void SerializerShouldNotThrowExceptions()
        {
            Contact bjorn = new Contact
            {
                ContactID = 123,
                Name = "Bjørn Bouet Smith",
                Emails = new List<string> { "bjornsmith@gmail.com" },
                Groups = new List<string> { "friends" },
                ContactUri = new Uri("http://localhost/addressbook/bjorn/contacts/123")
            };
            JsonSerializer ser = new JsonSerializer();
            using (MemoryStream ms = new MemoryStream())
            {
                ser.Serialize(bjorn, ms);
                Console.WriteLine(Encoding.UTF8.GetString(ms.ToArray()));
            }
        }

        private class Contact
        {
            public Contact()
            {
                Emails = new List<string>();
                Groups = new List<string>();
            }

            public long ContactID
            {
                get;
                set;
            }

            public Uri ContactUri
            {
                get;
                set;
            }

            public string Name
            {
                get;
                set;
            }

            public List<string> Emails
            {
                get;
                set;
            }

            public List<string> Groups
            {
                get;
                set;
            }
        }
    }
}
